package cn.edu.scau.cmi.suyaoxing.composite.safe;

import java.util.ArrayList;
import java.util.List;

public class SafeComposite implements SafeComponent{
	private List<SafeComponent> childs = new ArrayList<SafeComponent>();
	private int index;
	@Override
	public String doSomething() {
		return "Composite doSomething";
	}
	public SafeComposite(int index) {
		this.index=index;
	}
	public int getIndex() {
		return this.index;
	}
	@Override
	public String toString() {
		return "组织"+this.index;
	}
	public void addChild(SafeComponent child) {
		this.childs.add(child);
	}
	public void removeChild(int index) {
		this.childs.remove(index);
	}
	public int getSize() {
		return this.childs.size();
	}
	public SafeComponent getChild(int index) {
		return this.childs.get(index);
	}
	public List<SafeComponent> getList() {
		return this.childs;
	}
}
